#ifndef SNAILLTCPCLIENT_H
#define SNAILLTCPCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <QJsonDocument>
#include <QJsonObject>
class SnaillTcpClient : public QObject
{
    Q_OBJECT
public:
    static SnaillTcpClient* instance();
        // 连接到服务器
        bool connectToServer(const QString &host, quint16 port);
        // 发送 JSON 数据到服务器
        bool sendJsonData(const QJsonObject &jsonData);
        // 断开与服务器的连接SnaillTcpClient
        void disconnectFromServer();

signals:
        // 接收到服务器数据的信号
            void dataReceived(const QByteArray &data);
private slots:
    // 处理套接字准备好读取数据的槽函数
    void onReadyRead();

private:
    explicit SnaillTcpClient(QObject *parent = nullptr);
    ~SnaillTcpClient();
    static SnaillTcpClient* m_instance;
    QTcpSocket *m_socket;

};

#endif // SNAILLTCPCLIENT_H
